<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/5/19
 * Time: 9:04
 */

namespace front\modules\app\controllers;


use common\helpers\ReturnHelper;
use front\controllers\RestBaseController;
use front\helpers\OSS;
use yii\helpers\Json;

class AppController extends RestBaseController
{

    public function actionConversion()
    {
        $oss = OSS::boot('http://oss-cn-hangzhou.aliyuncs.com', 'lw1QaTmxneWlrnHW', 'phGNqTSAHe7jLWUaD6UG99mgNkXw1b');

        $obj = $oss->getObject('wdt-statics', array(
            'Prefix' => 'apk/'
        ));
        $arr = [];
        foreach ( $obj as $name ) {
            if (strstr ( $name, ".apk" )) {
                $arr['link'] = 'http://wdt-statics.oss-cn-hangzhou.aliyuncs.com/' . $name;
                $name = strrchr($name, ' ');
                $arr['conversion'] = substr($name, 0, -4);
            }
        }
        return ReturnHelper::success('success', $arr);
    }
}